﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;

namespace Views
{
    /// <summary>
    /// Interaction logic for frmUpdateDatabaseView.xaml
    /// </summary>
    public partial class frmUpdateDatabaseView : Window
    {
        Models.DataModel conn1 = new Models.DataModel();
        Models.DataModel conn2 = new Models.DataModel();
        List<DataTable> lstData = new List<DataTable>();
        string BeginDate = string.Empty;
        string EndDate = string.Empty;
        public frmUpdateDatabaseView()
        {
            InitializeComponent();
        }

        public frmUpdateDatabaseView(Models.DataModel conn1, Models.DataModel conn2, params DataTable[] tb)
        {
            InitializeComponent();
            lstData.Add(tb[0]);
            lstData.Add(tb[1]);
            lstData.Add(tb[2]);
            xdgTableDefine.DataSource = tb[0].DefaultView;//defire
            xdgTableIndex.DataSource = tb[1].DefaultView;//index
            xdgTableIdentity.DataSource = tb[2].DefaultView;//identity
            this.conn1 = conn1;
            this.conn2 = conn2;
        }

        //private void btnSyncDatabase_Click(object sender, RoutedEventArgs e)
        //{            
        //    DataTable tb = ModelViews.UpdateDatabaseModelView.CreateScript(conn1, lstData[0], lstData[1],lstData[2]);
        //    DataTable tbError1 = ModelViews.UpdateDatabaseModelView.BeginUpdateTable(conn2, tb); 
        //    DataTable tbError2 = ModelViews.UpdateDatabaseModelView.BeginUpdateStored(conn1,conn2,BeginDate,EndDate);
        //    DataTable tbError = Models.DataModel.MixTable(tbError1, tbError2);
        //    if (tbError.Rows.Count > 0)
        //        (new frmError(tbError)).Show();
        //    else
        //        MessageBox.Show("Synchronous Successfull!!!", "Message",MessageBoxButton.OK,MessageBoxImage.Asterisk);

        //    this.Close();
        //}

        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
